/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#ifndef SERIAL_H
#define SERIAL_H

#include <stdio.h>		/* standard i/o definitions */
#include <stdlib.h>		/* standard lib */
#include <math.h>		/* mathematical functions */
#include <string.h>		/* string function definitions */
#include <fcntl.h>		/* file control definition */
#include <errno.h>		/* error number definition */
#include <unistd.h>		/* UNIX standard functions */
#include <termios.h>		/* terminal control functions */
#include <time.h>		/* time manipulation functions */
#include <sys/ioctl.h>		/* i/o control, Unix specific */
#include <sys/select.h>		/* i/o management */

#include "my_limits.h"

/* serial communication constants */
#define SERIAL_BYTES_READ_COUNT 8	/* number of bytes to read at a time on the serial port */
#define SERIAL_BAUD_RATE B57600		/* baud rate of 57600, see constant definitions for tcsetattr */
#define SERIAL_WORD_LENGTH CS8		/* number of data bit per transferts */
#define SERIAL_PARITY 0			/* parity of serial communication (0=no, 1=odd, 2=even) */
#define SERIAL_STOP 1			/* stop bit of serial communication (1=one, 2=two) */

extern int syslog_flag;
extern char *serial_location;

int open_port(char *port_name);
int close_port(int file_descriptor);
int read_port(int file_descriptor,char *data_line,char *iso_time);
int clear_port(int file_descriptor);
int probe_port(int file_descriptor);
int set_port(int file_descriptor);
int dtr_up(int file_descriptor);
int dtr_down(int file_descriptor);

#endif
